package lx.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class JdbcDelete {
    public static void main(String[] args) throws  Exception {
        //加载驱动器
        Class.forName("com.mysql.jdbc.Driver");
        //获取连接
        String url = "jdbc:mysql://localhost:3306/test?useSSL=false";
        String username = "root";
        String password = "1102";
        Connection connection = DriverManager.getConnection(url, username, password);
        //创建陈述句对象
        Statement statement = connection.createStatement();
        String sql = "DELETE FROM `user` WHERE username = 'liqiang'";
        int i = statement.executeUpdate(sql);
        if(i>0){
            System.out.println("删除成功！");
        }
    }
}
